package h0720;

import java.util.Scanner;
import java.util.Stack;

public class PasswordCheckII {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String res = processInput(s);
        boolean checked = checkPassword(res);
        System.out.println(res+","+checked);
    }
    private static String processInput(String input){
        Stack<Character> stack=new Stack<>();
        for (char c : input.toCharArray()) {
            if (c=='<'){
                if (!stack.isEmpty()){
                    stack.pop();
                }
            }else {
                stack.push(c);
            }
        }
        StringBuilder result=new StringBuilder();
        while (!stack.isEmpty()){
            result.insert(0,stack.pop());
        }
        return result.toString();
    }

    private static boolean checkPassword(String password){
        if (password.length()<8){
            return false;
        }
        boolean hasUpperCase=false;
        boolean hasLowerCase=false;
        boolean hasDigit=false;
        boolean hasSpecialChar=false;

        for (char ch:password.toCharArray()){
            if (Character.isUpperCase(ch)){
                hasUpperCase=true;
            }else if (Character.isLowerCase(ch)){
                hasLowerCase=true;
            } else if (Character.isDigit(ch)) {
                hasDigit=true;
            }else {
                hasSpecialChar=true;
            }
        }
        return hasUpperCase&&hasLowerCase&&hasDigit&&hasSpecialChar;
    }
}
